#!/usr/bin/env python
# encoding:utf-8
'''
@author: yangyongjie
@license: (C) Copyright 2013-2017, Node Supply Chain Manager Corporation Limited. 
@contact: deamoncao100@gmail.com
software: garner
@file: 双人对战.py
@time: 2022/7/11 9:39
@desc:
'''
class Role():
    def __init__(self,name,sex,equipment,blood= 00):
        self.name = name
        self.sex = sex
        self.equipment = equipment
        self.blood = blood
        self.room = None

    def attak(self):
        print("普通攻击")
        if self.equipment == 1:
            self.blood -= 5
        else:
            self.blood -= 10

class Room():
    def __init__(self,name):
        self.name = name
        self.member_list = []

    def add_member(self,role):
        if role.room == None
            if len(self.member_list) <2
                self.member_list.append(role)
                role.room = self
                print(f"{role.name}已经加入了{self.name}")
        else:
            print(f"{role.name}已经加入{role.room.name}房间")

roles = dict()
rooms = dict()

def create_role():
    name,sex,equipment = input("请输入角色的姓名与性别，是否装备防弹衣，是为1，不是为0，空格分隔：、n")
    roles[name] = Role(name,sex,equipment)
    print(roles[name])

def create_room():
    room = input("请输入房间的名字：\n")
    rooms[room] = Room(room)

while 1:
    print(
          "1.创建角色\n"
          "2.创建房间\n"
          "3.加入房间\n"
          "4.开始游戏\n"
          "5.退出游戏\n"
          )
    in_option = int(input("请输入选项"))
    if in_option == 1:
        create_role()
    elif in_option == 2:
        create_room()
        print(rooms)
    elif in_option ==3 :
        print(f"当前有角色{roles.keys()},房间有{roors.keys()}")
        role_name,room_name = input("请输入您要加入的角色和房间名，空格分隔：\n".split())
        rooms[room_name].add_member(roles[role_name])
        elif in_option == 4:
        pass
        i = 1
        while 1:
            print("_" * 40)
            print(f"第----<{i}>----回合".center(33))
            i = i + 1
            print(f"{rooms[room_name].member_list[0].name}攻击方法——————》", end="")
            rooms[room_name].member_list[0].attack(rooms[room_name].member_list[1])

            if rooms[room_name].member_list[0].blood <= 0 or rooms[room_name].member_list[1].blood <= 0:
                winner = rooms[room_name].member_list[0].name if rooms[room_name].member_list[0].blood > 0 else \
                rooms[room_name].member_list[1].name
                print(f"{winner}---Win".center(40, "_"))
                break

            print(f"{rooms[room_name].member_list[1].name}攻击方法——————》", end="")
            rooms[room_name].member_list[1].attack(rooms[room_name].member_list[0])

            if rooms[room_name].member_list[0].blood <= 0 or rooms[room_name].member_list[1].blood <= 0:
                winner = rooms[room_name].member_list[0].name if rooms[room_name].member_list[0].blood > 0 else \
                rooms[room_name].member_list[1].name
                print(f"{winner}---Win".center(40, "_"))
                break
            # 输出双方的血量
            print(
                f"{rooms[room_name].member_list[0].name}:hp--{rooms[room_name].member_list[1].blood}    vs   {rooms[room_name].member_list[1].name}:hp--{rooms[room_name].member_list[1].blood}")

            print("_" * 40)
    elif in_option == 5:
        break
    else:
        print("输入错误！请输入1-5选择操作！")



















